package Levels 
{
	import Objetos.Fundos.Fundo1;
	import Objetos.Fundos.Fundo2;
	import Objetos.Inimigos.Chefe1;
	import Objetos.Inimigos.Inimigo1;
	import Objetos.Inimigos.Meteoro;
	import Objetos.Nave;
	import Objetos.Upgrades.Upgrade1;
	import Objetos.Upgrades.Upgrade2;
	import Objetos.Vida;
	/**
	 * ...
	 * @author Gabriel Ribeiro
	 */
	public class Level1 extends Level
	{
		protected var delayInimigo					:int;
		protected var delayUpgrade1					:int;
		protected var delayUpgrade2					:int;
		protected var delayChefe					:int;
		
		protected var BO_stop						:Boolean;
		
		public function Level1() 
		{
			delayInimigo = 30;
			delayUpgrade1 = 120;
			delayUpgrade2 = 120;
			delayChefe = 150
			
		}
		
		public function desenharTela():void
		{
			/*gameConstructor = new Fase1();
			gameConstructor.x = 0;
			gameConstructor.y = 0;
			Main.getInstance().MC_tela.addChild(gameConstructor);*/
			
			MC_fundo1 = new Fundo1();
			MC_fundo1.x = 400
			MC_fundo1.y = 600
			Level.AR_fundos.push(MC_fundo1)
			Main.getInstance().MC_tela.addChild(MC_fundo1);
			
			
			MC_nave = new Nave();
			MC_nave.x = 300;
			MC_nave.y = 300;
			Main.getInstance().MC_tela.addChild(MC_nave);
			
			MC_vida = new Vida();
			MC_vida.x = 130
			MC_vida.y = 70
			Main.getInstance().MC_tela.addChild(MC_vida);
			
			MC_inimigo1 = new Inimigo1();
			MC_inimigo1.x = 800;
			MC_inimigo1.y = 100;
			AR_inimigos.push(MC_inimigo1);
			BO_TirosI = true;
			Main.getInstance().MC_tela.addChild(MC_inimigo1);
			
			/*MC_chefe1 = new Chefe1();
			MC_chefe1.x = 400
			MC_chefe1.y = -50
			Main.getInstance().MC_tela.addChild(MC_chefe1);*/
		}
		
		
		
			override public function update():void
			{
				super.update();
				
				if (MC_fundo1.y >= 1200)
				{
					MC_fundo1.y = 600
				}
				
				if (delayChefe > 0)
				{
					delayChefe--
					
					if (BO_stop == false)
					{
						delayInimigo--;
						if (delayInimigo <= 0)
						{
							MC_met = new Meteoro();
							MC_met.x = 300
							MC_met.y = 0 - MC_met.height/2;
							Main.getInstance().MC_tela.addChild(MC_met);
							Level.AR_met.push(MC_met);
							delayInimigo = 30
						}
					}
				}
				
				/*delayInimigo--;
				if (delayInimigo <= 0)
				{
					MC_met = new Meteoro();
					MC_met.x = 300
					MC_met.y = 0 - MC_met.height/2;
					Main.getInstance().MC_tela.addChild(MC_met);
					Level.AR_met.push(MC_met);
					delayInimigo = 30
				}*/
				
				delayUpgrade1--;
				if (delayUpgrade1 <= 0)
				{
					MC_up1 = new Upgrade1();
					MC_up1.x = 400;
					MC_up1.y = 0 - MC_up1.height/2;
					Main.getInstance().MC_tela.addChild(MC_up1);
					delayUpgrade1 = 120;
				}
				
				delayUpgrade2--;
				if (delayUpgrade2 <= 0)
				{
					MC_up2 = new Upgrade2();
					MC_up2.x = 550;
					MC_up2.y = 0 - MC_up2.height/2;
					Main.getInstance().MC_tela.addChild(MC_up2);
					delayUpgrade2 = 120;
				}
				
				
				
				if (BO_stop == false)
				{
					if (delayChefe <= 0)
					{
						MC_chefe1 = new Chefe1();
						MC_chefe1.x = 400
						MC_chefe1.y = -50
						Main.getInstance().MC_tela.addChild(MC_chefe1);
						
						delayChefe = 300;
						BO_stop = true;
					}
				}
				
				if (MC_chefe1 != null)
				{
					MC_chefe1.update();
				}
				
				for (var i:int = 0; i < AR_tirosChefe1.length; i++)
				{
					if (AR_tirosChefe1[i] != null)
					{
						AR_tirosChefe1[i].update()
					}
				}
			}
	}

}